package hlhj.fhp.checkpoint.customView

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.View
import hlhj.fhp.checkpoint.R
import kotlinx.android.synthetic.main.dialog_choose_type.*

/**
 * Created by Never Fear   on 2018\11\19 0019.
Never More....
 */
class ChooseTypeDialog(c:Context,private val clickResultListener: ClickResultListener
,private val types:ArrayList<String>) :Dialog(c, R.style.MyDialog) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dialog_choose_type)


        btBig.setOnClickListener {
            clickResultListener.click("01")
            dismiss()
        }
        btSmall.setOnClickListener {
            clickResultListener.click("02")
            dismiss()
        }
        doType(types)
    }

    interface ClickResultListener{
        fun click(type:String)
    }

    fun doType(types:ArrayList<String>){
        if (types.size==2){
            btBig.visibility=View.VISIBLE
            btSmall.visibility=View.VISIBLE
        }else if (types.size==1){
            if (types[0].equals("01")){
                btSmall.visibility=View.GONE
            }else{
                btBig.visibility=View.GONE
            }
        }
    }
}